package 蓝桥真题;

public class 既约分数 {
	   final static int N=2030;
       static int primers[]=new int[N],phi[]=new int[N],cnt;
       static boolean st[]=new boolean[N];
	   public static void main(String[]args)throws Exception{
		      int n=2020;
		      phi[1]=1;
		      for(int i=2;i<=n;i++){
		    	  if(!st[i]){
		    		  phi[i]=i-1;
		    		  primers[cnt++]=i;
		    	  }
		    	  for(int j=0;primers[j]<=n/i;j++){
		    		  st[primers[j]*i]=true;
		    		  if(i%primers[j]==0){
		    			  phi[primers[j]*i]=phi[i]*primers[j];
		    			  break;
		    		  }else{
		    			  phi[primers[j]*i]=phi[i]*(primers[j]-1);
		    		  }
		    	  }
		      }
		      long res=0;
		      for(int i=1;i<=2020;i++)
		    	  res+=phi[i];
		      System.out.print(res*2-1);
	   }
}
